package cn.hxzy.icon.icon.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * (Resource)实体类
 *
 * @author makejava
 * @since 2020-08-13 11:56:54
 */
@Entity
@Table
@Data
public class Resource implements Serializable {
    private static final long serialVersionUID = 817538918254188114L;
    @Id
//    主键策略
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    /**
     * 名字
     */
    private String name;
    /**
     * 地址
     */
    private String url;
    /**
     * 父级id
     */
    private Integer pid;

    @CreationTimestamp//每次对象插入数据库就会有创建时间
    @Column(updatable = false)//插入数据库之后此字段不让修改
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")//转成json字符串时的格式和时区
    private Date createTime;

    @UpdateTimestamp//修改对象有修改时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")//转成json字符串时的格式和时区
    private Date updateTime;

    private Integer orderNumber;
    @Transient
    private List<Resource> son;

}